home *** CD-ROM | disk | FTP | other *** search
- //========================================================================================
- //
- // Ex-raw.c - Generic EDL export module.
- //
- // Part of the Adobe Premiere 4.2 Plug-in Developer's Toolkit.
- //
- // Copyright ⌐ 1993-96, Adobe Systems Incorporated, all rights reserved worldwide.
- //
- // Written by Randy Ubillos, Bryan K. "Beaker" Ressler, Nick Schlott.
- //
- // Version 1.00 10/20/93 Original version.
- // Version 1.01 10/30/94 Windows version.
- // Version 1.02 1/10/96 Updated for Premiere 4.2 and MSVC++ 2.2 & 4.2.
- //
- //========================================================================================
-
- #include <windows.h>
-
- #include "Compat.h"
- #include "Premiere.h"
-
-
- HINSTANCE ghInst;
-
- int ParseBlock(BlockRec *theblock, HFILE ref, int indent);
-
-
- BOOL WINAPI DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
- {
- switch (dwReason)
- {
- case DLL_PROCESS_ATTACH:
- ghInst = hDLL;
- break;
-
- case DLL_THREAD_ATTACH:
- break;
-
- case DLL_THREAD_DETACH:
- break;
-
- case DLL_PROCESS_DETACH:
- break;
- }
- return(TRUE);
- }
-
-
- //-----------------------------------------------
- // Chop the extension off a file name
-
- void ChopExtension (LPSTR str)
- {
- short n;
-
- n = lstrlen(str)-1;
- while(n)
- {
- if(str[n] == '.')
- {
- str[n] = 0;
- break;
- }
- else if(str[n] == '\\')
- break;
- n--;
- }
- }
-
-
- //-----------------------------------------------
- // Strip the file name off a full path
-
- LPSTR FileNameFromPath (LPSTR s)
- {
- int idx;
-
- if(s[1] != ':')
- return s;
-
- idx = lstrlen(s);
-
- while(idx && s[idx] != '\\')
- idx--;
- return &s[idx+1+(idx==0)];
- }
-
-
- //-------------------------------------------------------------------------------------------
- int PutFile (char *name, char *caption)
- {
- OPENFILENAME ofn;
-
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.lpstrFilter = "*.edl";
- ofn.hwndOwner = GetLastActivePopup(GetMainWnd());
- ofn.hInstance = ghInst;
- ofn.nFilterIndex = 0;
- ofn.lpstrFileTitle = NULL;
- ofn.nMaxFileTitle = 31;
- name[0] = 0;
- ofn.lpstrFile = (LPSTR)name;
- ofn.nMaxFile = _MAX_PATH;
- ofn.lpstrInitialDir = NULL;
- ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
- ofn.lpstrCustomFilter = NULL;
- ofn.nMaxCustFilter = 0;
- ofn.nFileOffset = ofn.nFileExtension = 0;
- ofn.lpstrDefExt = "EDL";
- ofn.lCustData = 0;
- ofn.lpfnHook = NULL;
- ofn.lpTemplateName = NULL;
- ofn.lpstrTitle=NULL;
-
- if (caption) ofn.lpstrTitle = caption;
- return GetSaveFileName(&ofn);
- }
-
-
- //-------------------------------------------------------------------------------------------
- // Export
-
- int PRMEXPORT xExport (short selector, ExportHandle theData)
- {
- short result = 0;
- HFILE ref;
- Str63 str1;
- FSSpec thespec;
- OFSTRUCT of;
-
- switch (selector)
- {
- case exExecute:
- LoadString(ghInst, 10001, str1, 63);
-
- lstrcpy(thespec.name, FileNameFromPath((*theData)->projectName));
- ChopExtension(thespec.name);
- LoadString(ghInst,10002, &thespec.name[lstrlen(thespec.name)], 10);
-
- if (PutFile(thespec.name, str1))
- {
- OpenFile(thespec.name, &of, OF_DELETE);
- ref = OpenFile(thespec.name, &of, OF_CREATE | OF_READWRITE);
- if (ref != HFILE_ERROR)
- {
- HLock((*theData)->dataHandle);
- ParseBlock((BlockRec*)*(*theData)->dataHandle,ref,0);
- HUnlock((*theData)->dataHandle);
- _lclose(ref);
- }
- }
- break;
- case exTrue30fps:
- result = true;
- break;
- }
- return(result);
- }
-
- //-------------------------------------------------------------------------------------------
- // Write data to a file
-
- int WriteFileX (HFILE ref, Ptr data, long length)
- {
- return(_hwrite(ref,data,length) != length);
- }
-
- //-------------------------------------------------------------------------------------------
- // Send a character to a file
-
- int SendChar (HFILE ref, char ch)
- {
- return(WriteFileX(ref,&ch,1));
- }
-
- //-------------------------------------------------------------------------------------------
- // Send a string to a file
-
- int WriteString (HFILE ref, char *str)
- {
- return(WriteFileX(ref,str,lstrlen(str)));
- }
-
- //-------------------------------------------------------------------------------------------
- // Send a number to a file
-
- int SendNum (HFILE ref, long num)
- {
- Str27 str;
-
- wsprintf(str, "%ld", num);
- return(WriteString(ref,(char *)str));
- }
-
- //-------------------------------------------------------------------------------------------
- // Send a string to a file
- // str is formatted like fprint (kind of...)
-
- int SendStr (HFILE ref, char *str, long value, ...)
- {
- char *where,*last, *start, oldchar, temp[10];
- short param = 0, err = 0, i, num;
- long *parm = &value;
-
- where = str;
- last = str + lstrlen(str);
- while (!err && (where <= last))
- {
- start = where;
- if (where[0] == '%')
- {
- switch (where[1])
- {
- case 'd':
- err = SendNum(ref,parm[param++]);
- break;
- case 's':
- err = WriteString(ref,(char*)parm[param++]);
- break;
- case 't':
- temp[4] = 0;
- *((long*)(temp)) = parm[param++];
- err = WriteString(ref,temp);
- break;
- case 'b':
- temp[8] = 0;
- num = (short)parm[param++];
- for (i=0; i<=7; i++) temp[i] = num & (0x0080>>i) ? '1':'0';
- err = WriteString(ref,temp);
- break;
- }
- where += 2;
- }
- else
- {
- while ((where<=last) && (where[0]!='%'))
- where++;
-
- oldchar = *where;
- *where = 0;
- err = WriteString(ref,(char*)(start));
- *where = oldchar;
- }
- }
- return(err);
- }
-
- //-------------------------------------------------------------------------------------------
- // send out spaces to do an indent
-
- int SendIndent (HFILE ref, int amount)
- {
- int i, err=0;
-
- for (i = 0; !err && (i<amount); i++) err = SendChar(ref, 9);
- return(err);
- }
-
- //-------------------------------------------------------------------------------------------
- // take apart a block
-
- int ParseBlock (BlockRec *theblock, HFILE ref, int indent)
- {
- int i, count, svalue, err=0, mapping;
- long len, lvalue;
- Rec_BLOK rBLOK;
- Rec_TREC rTREC;
- Rec_CLIP rCLIP;
- Rec_RPNT rRPNT;
- Rec_MREC rMREC;
- Rec_VIDI rVIDI;
- Rec_FXOP rFXOP;
- Rec_TIMB rTIMB;
- FSSpec rFILE;
- COLORREF thecolor;
- RECT box;
- POINT pt;
- char str[32];
- Ptr pblock,p;
-
- err = SendIndent(ref, indent);
- if (!err) err = SendChar(ref,'[');
- if (!err) switch (theblock->type) {
- case bBLOK:
- len = sizeof(Rec_BLOK);
- ExtractBlockData(theblock,&rBLOK,&len);
- err = SendStr(ref,"'Adobe Premiere¬ 4.2 Generic Edit Decision List',Work_Start=%d,Work_End=%d",
- rBLOK.start,rBLOK.end);
- break;
- case bTRKB:
- err = SendStr(ref,"Tracks",nil);
- break;
- case bTRAK:
- err = SendStr(ref,"Track #%d",theblock->theID);
- break;
- case bFVID:
- err = SendStr(ref,"Video",nil);
- break;
- case bFSUP:
- err = SendStr(ref,"SuperImpose",nil);
- break;
- case bFAUD:
- err = SendStr(ref,"Audio",nil);
- break;
- case bFF_X:
- err = SendStr(ref,"FX",nil);
- break;
- case bAMAP:
- len = sizeof(mapping);
- ExtractBlockData(theblock, &mapping, &len);
- err = SendStr(ref, "Mapping=%b",mapping);
- break;
- case bTREC:
- len = sizeof(Rec_TREC);
- ExtractBlockData(theblock,&rTREC,&len);
- err = SendStr(ref,
- "Track_Record #%d, ClipID=%d, Start=%d, End=%d",
- theblock->theID,
- (long)rTREC.clipID,
- rTREC.start,
- rTREC.end);
- break;
- case bFXOP:
- len = sizeof(Rec_FXOP);
- ExtractBlockData(theblock,&rFXOP,&len);
- err = SendStr(ref,
- "FX_Options,Corners=%b,Direction=%d,Start=%d,End=%d",
- (long)rFXOP.corners,
- (long)rFXOP.direction,
- (long)rFXOP.startPercent,
- (long)rFXOP.endPercent);
- break;
- case bFXDF:
- len = sizeof(long);
- ExtractBlockData(theblock,&lvalue,&len);
- err = SendStr(ref,"FX_Type=%t",lvalue);
- break;
- case bEDGE:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Edge,Thickness=%d",(long)svalue);
- break;
- case bRBND:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"RubberBand, Max=%d",(long)svalue);
- break;
- case bRPNT:
- len = sizeof(Rec_RPNT);
- ExtractBlockData(theblock,&rRPNT,&len);
- err = SendStr(ref,
- "Band_Point #%d,h=%d,v=%d",
- theblock->theID,
- rRPNT.h,
- (long)rRPNT.v);
- break;
- case bOVER:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- LoadString(ghInst, 10101+svalue, str,32);
- err = SendStr(ref,"Overlay, Type='%s'",(long)str);
- break;
- case bCOLR:
- len = sizeof(COLORREF);
- ExtractBlockData(theblock,&thecolor,&len);
- err = SendStr(ref,
- "Color,Red=%d,Green=%d,Blue=%d",
- (long)GetRValue(thecolor),
- (long)GetGValue(thecolor),
- (long)GetBValue(thecolor));
- break;
- case bSIMI:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Similarity=%d",(long)svalue);
- break;
- case bBLND:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Blend=%d",(long)svalue);
- break;
- case bTHRS:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Threshold=%d",(long)svalue);
- break;
- case bCUTO:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Cutoff=%d",(long)svalue);
- break;
- case bALIA:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Anti-Aliasing=%d",(long)svalue);
- break;
- case bSHAD:
- err = SendStr(ref,"Shadow",nil);
- break;
- case bRVRS:
- err = SendStr(ref,"Key_Reversed",nil);
- break;
- case bGARB:
- len = sizeof(RECT);
- ExtractBlockData(theblock,&box,&len);
- err = SendStr(ref,
- "Garbage_Matte,Left=%d,Top=%d,Right=%d,Bottom=%d",
- (long)box.left,
- (long)box.top,
- (long)box.right,
- (long)box.bottom);
- break;
- case bPONT:
- len = sizeof(POINT);
- ExtractBlockData(theblock,&pt,&len);
- err = SendStr(ref,
- "Point #%d,h=%d,v=%d",
- theblock->theID,
- (long)pt.x,
- (long)pt.y);
- break;
- case bMATI:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"MatteID=%d",(long)svalue);
- break;
- case bVFLT:
- err = SendStr(ref,"Video_Filters",nil);
- break;
- case bAFLT:
- err = SendStr(ref,"Audio_Filters",nil);
- break;
- case bFILT:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"FileID=%d",(long)svalue);
- break;
- case bMOTN:
- len = sizeof(RECT);
- ExtractBlockData(theblock,&box,&len);
- err = SendStr(ref,
- "Motion,Left=%d,Top=%d,Right=%d,Bottom=%d",
- (long)box.left,
- (long)box.top,
- (long)box.right,
- (long)box.bottom);
- break;
- case bSMTH:
- err = SendStr(ref,"Smooth",nil);
- break;
- case bMREC:
- len = sizeof(Rec_MREC);
- ExtractBlockData(theblock,&rMREC,&len);
- err = SendStr(ref,
- "Motion_Point #%d,Zoom=%d,Time=%d,Delay=%d,Rotation=%d,h=%d,v=%d",
- theblock->theID,
- (long)rMREC.zoom,
- (long)rMREC.time,
- (long)rMREC.delay,
- (long)rMREC.rotation,
- (long)rMREC.spot.x,
- (long)rMREC.spot.y);
- break;
- case bDATA:
- err = SendStr(ref,"Data #%d, %d bytes",theblock->theID,theblock->dataSize);
- break;
-
- case bCLPB:
- err = SendStr(ref,"Clips",nil);
- break;
- case bCLIP:
- len = sizeof(Rec_CLIP);
- ExtractBlockData(theblock,&rCLIP,&len);
- err = SendStr(ref,
- "ClipID #%d,FileID=%d,In=%d,Out=%d",
- theblock->theID,
- (long)rCLIP.fileID,
- rCLIP.in,
- rCLIP.out);
- break;
- case bMARK:
- len = sizeof(long);
- ExtractBlockData(theblock,&lvalue,&len);
- err = SendStr(ref,"Mark #%d, Location=%d",theblock->theID,lvalue);
- break;
- case bLOCK:
- err = SendStr(ref,"Aspect_Locked",nil);
- break;
- case bRATE:
- len = sizeof(short);
- ExtractBlockData(theblock,&svalue,&len);
- err = SendStr(ref,"Rate=%d",(long)svalue);
- break;
-
- case bFILB:
- err = SendStr(ref,"Files",nil);
- break;
- case bFILE:
- err = SendStr(ref,"FileID #%d",theblock->theID);
- break;
- case bMACS:
- len = sizeof(FSSpec);
- ExtractBlockData(theblock,&rFILE,&len);
- err = SendStr(ref,"Mac_Spec,Name='%s',vRefNum=%d,parID=%d",
- (long)rFILE.name,rFILE.vRefNum,rFILE.parID);
- break;
- case bMACP:
- len = 256;
- if (p = NewPtr(256)) {
- ExtractBlockData(theblock,p,&len);
- err = SendStr(ref,"Mac_Path='%s'",(long)p);
- DisposPtr(p);
- }
- break;
- case bDOSF:
- len = 256;
- if (p = NewPtr(256)) {
- ExtractBlockData(theblock,p,&len);
- err = SendStr(ref,"DOS_File='%s'",(long)p);
- DisposPtr(p);
- }
- break;
- case bFRMS:
- len = sizeof(long);
- ExtractBlockData(theblock,&lvalue,&len);
- err = SendStr(ref,"Num_Frames=%d",lvalue);
- break;
- case bVIDI:
- len = sizeof(Rec_VIDI);
- ExtractBlockData(theblock,&rVIDI,&len);
- err = SendStr(ref,
- "Video,Width=%d,Height=%d,Depth=%d",
- (long)rVIDI.frame.right,
- (long)rVIDI.frame.bottom,
- (long)rVIDI.depth);
- break;
- case bAUDI:
- len = sizeof(long);
- ExtractBlockData(theblock,&lvalue,&len);
- err = SendStr(ref,"Audio,Rate=%d",lvalue);
- break;
- case bTIMC:
- if (pblock = NewPtr(256))
- {
- len = 256;
- ExtractBlockData(theblock,pblock,&len);
- err = SendStr(ref,"Timecode String='%s'",(long)pblock);
- DisposPtr(pblock);
- }
- break;
- case bTIMB:
- len = sizeof(Rec_TIMB);
- ExtractBlockData(theblock,&rTIMB,&len);
- err = SendStr(ref,
- "Timecode Block,Frame=%d,DropFrame=%d,Format=%d",
- rTIMB.frames,
- (long)rTIMB.dropframe,
- (long)rTIMB.format);
- break;
- case bREEL:
- if (pblock = NewPtr(256))
- {
- len = 256;
- ExtractBlockData(theblock,pblock,&len);
- err = SendStr(ref,"Reel_Name='%s'",(long)pblock);
- DisposPtr(pblock);
- }
- break;
-
- default:
- err = SendStr(ref,"'*** Unknown: '%t' #%d, %d bytes",
- theblock->type,theblock->theID,theblock->dataSize);
- break;
- }
-
- if (!err)
- if ((unsigned)theblock->size > (sizeof(BlockRec) + theblock->dataSize))
- {
- err = SendChar(ref,',');
- if (!err) err = SendChar(ref,13);
- if (!err) err = SendChar(ref,10);
- count = (short)CountTypeBlocks(-1,theblock);
- for (i=0; !err && (i<count); i++)
- err = ParseBlock(FindBlock(-1,-1,i,theblock),ref,indent+1);
- SendIndent(ref,indent);
- }
- if (!err) err = SendChar(ref,']');
- if (!err && indent) err = SendChar(ref,',');
- if (!err) err = SendChar(ref,13);
- if (!err) err = SendChar(ref,10);
- return(err);
- }
-